import Mock from "mockjs";
let { data } = Mock.mock({
 
  "data|26": [
    {
      name: "@cname",
      "city|1":["上城区","下沙区","西湖区","拱墅区"],
      "time": "@date",
      "id|3-5":3,
      img:"@Image('100x100','@color','包子')",
      "comments|1":["地理位置好，交通方便，房间舒适卫生，服务人员很热情，乐于提供各种帮助，小姑娘非常热情，值得奖励。","位置优越交通便利，3条地铁站出门几分钟就走到了。公寓设施齐全，房间干净整洁，住的很舒服。服务人员都很好，很主动，热情。","超级喜欢，心水很久呢，一个人在异乡的小出租屋，只有它温暖的陪伴，愿我的生活也能如此多彩!","表锅，几个金的超棒滴喔"]
    },
  ],
});
Mock.mock("/api/comment","post",(options)=>{
 
  
  const{city,dengji,name} = JSON.parse(options.body)
  console.log(JSON.parse(options.body));
  let result
  if(city&&dengji){
    result = data.filter((item:any) => item.city === city && item.id === dengji)
  } else {
    result = data;
  }
  if (name){
    result = data.filter((item:any)=> item.name === name)
  } else {
    result = data
  }
  return{
    status:0,
    result:result
  }
})

Mock.mock("/api/comment/sousuo","post",(options)=>{
 
  
  const{name} = JSON.parse(options.body)
  console.log(JSON.parse(options.body));
  let result

  if (name){
    result = data.filter((item:any)=> item.name === name)
  } else {
    result = data
  }
  return{
    status:0,
    result:result
  }
})



export default Mock;